<!--编辑右侧弹框-->
<template>
  <!--<el-drawer
    size="532px"
    title="成片配置"
    :visible="visible"
    @close="updateVisible(false)">
    </el-drawer>
    -->
  <ele-modal
    width="500px"
    :visible="visible"
    :append-to-body="true"
    :close-on-click-modal="true"
    custom-class="ele-dialog-form"
    :title="form.packageName ? form.packageName : ''"
    @update:visible="updateVisible"
  >
    <el-form
      ref="form"
      :model="form"
      :rules="rules"
      :hide-required-asterisk="false"
      label-width="80px"
      @keyup.enter.native="submit"
      @submit.native.prevent
    >
      <el-form-item label="套餐价格" prop="packagePrice">
        <el-input
          class="delInput"
          type="number"
          step="0.01"
          v-model="form.packagePrice"
          placeholder="请输入当前套餐价格"
          clearable
        />
      </el-form-item>
      <div class="d-absolute flex-end m-bottom10">
        <el-button round @click="updateVisible(false)">取消</el-button>
        <el-button type="primary" class="margin20" round @click="save" :loading="loading">保存</el-button>
      </div>
    </el-form>
  </ele-modal>
</template>

<script>
  import {saveAgentCamera} from "@/api/lncomingManagement/carmeraAgent"
  export default {
    name: "pop-edit",
    props:{
      visible:Boolean
    },
    data(){
      return{
        loading:false,
        form:{},
        // 表单验证规则
        rules: {
          packagePrice: [
            {
              required: true,
              message: '请输入当前套餐价格',
              trigger: 'blur'
            }
          ]
        },
      }
    },
    methods: {
      show(row){
        this.form=row
      },
      /* 更新 visible */
      updateVisible(value) {
        this.$emit('update:visible', value);
      },
      // 保存
      save(){
        this.$refs.form.validate((valid) => {
          if (valid) {
            console.log("this.form",this.form)
            Object.assign(this.form,{
              oemId:this.$store.state.user.info.oemId  //代理ID
            });
            this.loading=true
            saveAgentCamera(this.form)
              .then((data) => {
                this.$message.success(data.msg);
                this.$emit('done')
                this.loading=false
                this.updateVisible(false)
              })
              .catch((e) => {
                this.loading=false
                this.$message.error(e.msg);
              });
          } else {
            return false;
          }
        });
      }
    }
  }
</script>

<style scoped lang="less">
  .d-absolute{
    /*position: absolute;
    bottom: 30px;
    right: 10px;*/
  }
  /*隐藏input（type=number)右边的小箭头*/
  /deep/.delInput input::-webkit-outer-spin-button,
  /deep/.delInput input::-webkit-inner-spin-button {
    -webkit-appearance: none!important;
  }
  /deep/.delInput input[type="number"]{
    -moz-appearance: textfield;
  }
</style>
